package com.example.memurbac_service.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig
{

  @Bean
  public Docket getDocket(){
      return new Docket(DocumentationType.SWAGGER_2)
              //所有需要文档化的API（接口）对象
              .apiInfo(getApiinfo())
              //select()指定构造选择器，
              .select()
              //根据类型选择Api
              //.apis(RequestHandlerSelectors.withClassAnnotation(Controller.class))
              //选择根据包路径扫描api
              .apis(RequestHandlerSelectors.basePackage("com.example.memurbac_service"))
              // paths()/指定路径
              .paths(PathSelectors.any())
              // build()模式创建Docket对象
              .build();

  }

    private ApiInfo getApiinfo(){
        //通过apibuider对象构造apiinfo对象
        return new ApiInfoBuilder()
                //指定文档标题
                .title("MEMURBACSERVICE  接口")
                //配置接口详细信息
                .description("接口详细信息")
                //指定版本信息
                .version("v1.0.0")
                //指定联系人信息
                .contact(new Contact("gzj", "no", "2100194580@qq.com"))
                //构造Apiinfo对象
                .build();
    }
}
